#!/bin/bash
#
# Usage: ./create_fifs_db.sh <database name> <username> [<password>]
#

if [ $# -lt 2 ]
then
  echo "Usage: create_fifs_db.sh <database name> <user> [<password>]"
  exit -1
fi

echo "[create_fifs_db] dropping old database $1, if any"
mysqladmin -f --user=$2 --password=$3 drop $1

echo "[create_fifs_db] creating database '$1'"
mysqladmin -f --user=$2 --password=$3 create $1

echo "[create_fifs_db] creating database '$1' tables"
mysql -f --user=$2 --password=$3 $1 < lib/fifs.sql

echo "[create_fifs_db] database '$1' created"
